package com.qfedu.dao;

import com.qfedu.entity.Staff;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StaffDao {

    @Select("select * from t_staff where u_no = #{no}")
    Staff findStaffByNo(String no);



    @Insert("insert into t_staff (u_no, d_id, name, sex, email, qq, phone, heading, entryTime, flag) VALUE (#{u_no},#{d_id},#{name},#{sex},#{email},#{qq},#{phone},#{heading},#{entryTime},#{flag})")
    public int staffAdd(Staff staff);

    @Select("select ts.id as id, ts.u_no as u_no, ts.name as name,ts.sex as sex,ts.email as email,ts.qq as qq,ts.phone as phone,ts.heading as heading,entryTime as entryTime,ts.flag as flag,td.name as depart from t_staff ts left join t_depart td on ts.d_id = td.id")
    public List<Staff> findAll();

    @Delete("delete from t_staff where id = #{id}")
    public int delete(int id);
}
